<?PHP
// vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+
// | SAPID: XML Sapiens Engine Demonstrator                               |
// +----------------------------------------------------------------------+
// | Author:  Max Baryshnikov aka Mephius <mb@rg.by>	                  |
// | Copyright (c) 2004 Max Baryshnikov                                   |
// | http://sapid.sourceforge.net	                                      |
// +----------------------------------------------------------------------+
// | This source file is free software; you can redistribute it and/or    |
// | modify it under the terms of the GNU Lesser General Public           |
// | License as published by the Free Software Foundation; either         |
// | version 2.1 of the License, or (at your option) any later version.   |
// |                                                                      |
// | This source file is distributed in the hope that it will be useful,  |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
// | Lesser General Public License for more details.                      |
// +----------------------------------------------------------------------+
// Release: 07.12.04 (dd/mm/yy)
// $Id: tree.php,v 1.6 2006/02/20 08:39:46 sheiko Exp $

include("../../etc/rc.conf.php");

	$fp=fopen($root_path . "usr/xml/tree.xml", "r");
	$contents=fread($fp, filesize($root_path . "usr/xml/tree.xml"));
	fclose($fp);
	
if(COMPRESS_XML and function_exists("gzcompress")){

	$output = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
	$output .= substr(gzcompress($contents, 9), 0, -4);

	header("Content-type: text/xml; charset=UTF-8");	
	header("Pragma: no-cache");
	header("Accept-Ranges: bytes");
	header("Content-Encoding: gzip");
	header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
	header('Content-Length: ' . strlen($output));

	echo $output;
}else{
	header("Content-type: text/xml; charset=utf-8");	
	header("Pragma: no-cache");
	header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
	header("Accept-Ranges: bytes");
	header('Content-Length: ' . filesize($root_path . "usr/xml/tree.xml"));

	echo $contents;
}
?>